﻿@model TaxTypeSelectorModel
@using Nop.Core.Domain.Tax;
@using Nop.Web.Models.Common;
@using Nop.Web.Framework.Themes;
@using Nop.Core.Infrastructure;
@using Nop.Core;
@if (Model.Enabled)
{
    var webHelper = EngineContext.Current.Resolve<IWebHelper>();
    
    var theme = EngineContext.Current.Resolve<IThemeContext>().WorkingDesktopTheme;

    Html.AddScriptParts(String.Format("~/Themes/{0}/Content/Scripts/jquery.styleSelect.min.js", theme));
    Html.AddScriptParts(String.Format("~/Themes/{0}/Content/Scripts/jquery.jscrollpane.min.js", theme));

    var taxTypes = new List<SelectListItem>();
    taxTypes.Add(new SelectListItem()
    {
        Text = T("Tax.Inclusive").Text,
        Value = webHelper.ModifyQueryString(Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.IncludingTax) }), "returnurl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl), null),
        Selected = Model.CurrentTaxType == TaxDisplayType.IncludingTax
    });
    taxTypes.Add(new SelectListItem()
    {
        Text = T("Tax.Exclusive").Text,
        Value = webHelper.ModifyQueryString(Url.RouteUrl("ChangeTaxType", new { customertaxtype = ((int)TaxDisplayType.ExcludingTax) }), "returnurl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl), null),
        Selected = Model.CurrentTaxType == TaxDisplayType.ExcludingTax
    });
    
    <div class="header-taxdisplaytypeselector">
    
        @Html.DropDownList("customerTaxType", taxTypes, new { onchange = "setLocation(this.value);" })

        <script type="text/javascript">

            $(document).ready(function () {


                var options = {
                    styleClass: "new_select",
                    jScrollPane: 1
                }

                $("#customerTaxType").styleSelect(options);

            });

        </script>     
    </div>
}